﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Mycontrol_Dat_tour_theo_yeu__cau : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btn_tro_lai_Click(object sender, EventArgs e)
    {
        Response.Redirect("/");

    }
    protected void cklist (object sender, EventArgs e)
    {
        this.lblThongBao.Text = "";
        foreach (ListItem item in ckloaihinh.Items)
        {
            if (item.Selected)
            {
                //this.lblThongBao.Text += item.Value + " - ";
                string loaihinh = item.Value +" - ";
                this.lblThongBao.Text += loaihinh;
            }
        }
    }
    protected void btn_gui_yeu_cau_Click(object sender, EventArgs e)
    {   
        //check so lieu
        TourYeuCau TourYeuCau = new TourYeuCau();
        Utils utils = new Utils();
        List<WebControl> lstWebcontrol = new List<WebControl>();
        lstWebcontrol.Add(txthoten);
        lstWebcontrol.Add(txttinh);
        lstWebcontrol.Add(txtdiachi);
        lstWebcontrol.Add(txtsodienthoai);
        lstWebcontrol.Add(txtemail);
        lstWebcontrol.Add(txtsonguoi);
        //lstWebcontrol.Add(ckloaihinh.SelectedIndex.ToString());
        lb_messenger1.Text=utils.checkNull(lstWebcontrol);
        if (lb_messenger1.Text == "")
        {

            //check so lieu: email, integer

            lb_messenger1.Text = utils.checkDataType(lstWebcontrol);
            if (lb_messenger1.Text == "")
            {
                ObjTourYeuCau objTourYeuCau = new ObjTourYeuCau();
                objTourYeuCau.Ho_ten = txthoten.Text;
                objTourYeuCau.Tinh = txttinh.Text;
                objTourYeuCau.Dia_chi = txtdiachi.Text;
                objTourYeuCau.Dia_diem = txtdiadiem.Text;
                objTourYeuCau.Email = txtemail.Text;
                objTourYeuCau.So_dien_thoai = txtsodienthoai.Text;
                objTourYeuCau.So_nguoi = int.Parse(txtsonguoi.Text);
                objTourYeuCau.Thoi_gian = txtthoigian.Text;
                objTourYeuCau.Ten_co_quan = txttencoquan.Text;
                objTourYeuCau.Yeu_cau = txtyeucau.Text;
                foreach (ListItem item in ckloaihinh.Items)
                {
                    if (item.Selected)
                    {
                        //this.lblThongBao.Text += item.Value + " - ";
                        string loaihinh = item.Value + " - ";
                    }
                }
                objTourYeuCau.Loai_hinh_du_lich = lblThongBao.Text;
                
                TourYeuCau.createTourYeuCau(objTourYeuCau);
                lb_messenger1.Text = "Bạn đã gửi thông tin thành công!";
            }
            else
            {
                lb_messenger1.Text = "Bạn chưa có thông tin";
            }
        }

    }
}